package com.yuan.springcloud.producer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

/**
 * 消息发送工具类
 * @author YouYuan
 * @date 2020/4/6 2:03
 */
@Component
@EnableBinding(Source.class)
public class MessageSender {

    @Autowired
    private MessageChannel output;

    /**
     * 发送消息
     * @param object
     */
    public void send(Object object) {
        output.send(MessageBuilder.withPayload(object).build());
    }

}
